package com.tang.common.exception.eumes;

import com.tang.common.constant.HttpStatus;
import lombok.Data;

public interface Error {


    ErrorCodeMessage NOT_IMPLEMENTED = create(500, "还未实现");

    ErrorCodeMessage NOT_ENUM = create(500, "此字典不是枚举类型");

    ErrorCodeMessage ARGUMENT_ERROR = create(500, "参数错误");

    ErrorCodeMessage OPERATE_ERROR = create(500, "操作失败，请重新尝试");

    ErrorCodeMessage USERNAME_NOT_EXIST = create(500, "用户名不存在");

    ErrorCodeMessage UNKNOWN_PAY_METHOD = create(500, "未知的支付方法");



    ErrorCodeMessage SHARD_LOCK_EXPRESSION_ERROR = create(500, "分布式锁value非法，%s少于或多于表达式值：%s");



    @Data
    class ErrorCodeMessage {
        private ErrorCodeMessage(Integer code, String message) {
            this.code = code;
            this.message = message;
        }

        private final Integer code;
        private final String message;
    }

    /**
     * 创建错误信息
     *
     * @param code
     * @param message
     * @return
     */
    static ErrorCodeMessage create(Integer code, String message) {
        return new ErrorCodeMessage(code, message);
    }

    /**
     * 创建错误信息
     *
     * @param message
     * @return
     */
    static ErrorCodeMessage create( String message) {
        return new ErrorCodeMessage(HttpStatus.ERROR, message);
    }
}
